/*
 * PlaylistRemoveAction.java
 *
 * Created on April 8, 2006, 1:49 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package com.bff.slimserver.musicjukebox.lib.actions;

import com.bff.slimserver.musicjukebox.lib.JukeboxProperties;
import com.bff.bjj.utils.Resources;
import java.awt.event.ActionEvent;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.AbstractAction;
import javax.swing.Action;
import org.bff.slimserver.SlimSavedPlaylistManager;
import org.bff.slimserver.exception.SlimConnectionException;
import org.bff.slimserver.exception.SlimException;
import org.bff.slimserver.musicobjects.SlimPlaylistItem;
import org.bff.slimserver.musicobjects.SlimSavedPlaylist;

/**
 *
 * @author Bill
 */
public class SavedPlaylistRemoveSongAction extends AbstractAction {

    private SlimSavedPlaylistManager playlistManager;
    private SlimPlaylistItem object;
    private SlimSavedPlaylist playlist;

    /** Creates a new instance of PlaylistInsertAction */
    public SavedPlaylistRemoveSongAction(SlimSavedPlaylist playlist, SlimPlaylistItem object) {
        this.playlist = playlist;
        this.object = object;
        try {
            this.playlistManager = JukeboxProperties.getInstance().getPlaylistManager();
        } catch (SlimConnectionException ex) {
            Logger.getLogger(SavedPlaylistRemoveSongAction.class.getName()).log(Level.SEVERE, null, ex);
        }
        putValue(Action.NAME, Resources.getMessage(Resources.LABEL_KEY.ACTION_SAVED_PLAYLIST_REMOVE_SONG_NAME));
        putValue(Action.SMALL_ICON, Resources.getIcon(Resources.ICON_KEY.ACTION_SAVED_PLAYLIST_REMOVE_SONG));
        putValue(Action.SHORT_DESCRIPTION, Resources.getMessage(Resources.LABEL_KEY.ACTION_SAVED_PLAYLIST_REMOVE_SONG_SHORT_DESC));
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        try {
            playlistManager.deletePlaylistSong(playlist, object);
        } catch (SlimException ex) {
            Logger.getLogger(SavedPlaylistRemoveSongAction.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
